package com.davies.learn.jbv.domain.dto;



import com.davies.learn.jbv.configuration.UserTypeGroupSequenceProvider;
import com.davies.learn.jbv.domain.enums.UserType;
import jakarta.validation.constraints.DecimalMin;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hibernate.validator.group.GroupSequenceProvider;

import java.math.BigDecimal;

/**
 * @author davies
 * @date 2023/7/16 10:54
 */
@GroupSequenceProvider(UserTypeGroupSequenceProvider.class)
@Data
public class UserSaveDTO {

    @NotBlank
    private String username;

    /**
     * 用户类型
     * S_VIP(0),
     * VIP(1),
     * NORMAL(2)
     */
    @NotNull
    private UserType userType;


    /**
     * SVIP 要求金额至少100
     * VIP 要求金额至少10
     * NORMAL 要求金额至少1
     */
    @NotNull
    @DecimalMin(value = "100",groups = UserTypeGroup.SVip.class,
    message = "SVIP {amount.error}")
    @DecimalMin(value = "10",groups = UserTypeGroup.Vip.class,
            message = "{vip.amount.error}")
    @DecimalMin(value = "1",groups = UserTypeGroup.Normal.class,
            message = "NORMAL {amount.error}")
    private BigDecimal amount;





}
